﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebSite.Models.QueryModel>" %>
<%@ Import Namespace="WebSite.Models" %>
<%@ Import Namespace="WebSite.App_Code" %>
<%@ Import Namespace="WebSite.App_Data" %>

<%@ Register src="../Shared/PageTool.ascx" tagname="PageTool" tagprefix="uc_PT" %>

    <script type="text/javascript">

        $(document).ready(function () {

            $("td[G=1]", $("#QueryTable")).hide();
            $("td[G=2]", $("#QueryTable")).hide();
            $("td[G=3]", $("#QueryTable")).hide();
            $("td[G=4]", $("#QueryTable")).hide();
            $("td[G=5]", $("#QueryTable")).hide();

        });

        function BudgetTable_CheckAll(sender) {

            if ($(sender).attr("checked") == "checked") 
                $("input[type=checkbox]:eq(0)", $("tr", $("#QueryTable"))).attr("checked", "checked");
            else
                $("input[type=checkbox]:eq(0)", $("tr", $("#QueryTable"))).removeAttr("checked", "");
        }

        function Open(sender, num) {

            if ($(sender).val() == "+") {
                $("td[G=" + num + "]", $("#QueryTable")).show();
                $(sender).val("-")
            }
            else {
                $("td[G=" + num + "]", $("#QueryTable")).hide();
                $(sender).val("+")
            }
        }

        function OpenBudegtPage(id, his, version, type) {
            window.open("../Budget/BudgetDetail?id=" + id + "&his=" + his + "&version=" + version + "&type=" + type);
        }

    </script>

    <style type="text/css">
    
    .List
    {
         background-color:White;
    }
     
    .List .header td
    {
        border:2px solid #385D8A;
        border-left:none;
        white-space:nowrap;
        padding:5px;
        background-color:#4F81BD;
        color:White;
    }
    
    .List .body td
    {
        border:2px solid #385D8A;
        border-top:none;
        border-left:none;
        white-space:nowrap;
        padding:5px;
    }
    
    .List .header .first
    {
        border-left:2px solid #385D8A;
        white-space:nowrap;
        padding:5px;
    }
    
    .List .header .hiden
    {
        background-color:#595959;
    }
    
    .List .body .first
    {
        border-left:2px solid #385D8A;
        white-space:nowrap;
        padding:5px;
    }
    
    .List .header .blank, .List .body .blank
    {
        background-color:#D8E5D3;
        border-top:none;
        border-bottom:none;
    }
    
    .List .header .warning
    {
        background-color:#C0504D;
    }
    
    </style>

    <table border="0" cellpadding="0" cellspacing="0" class="List" id="QueryTable">
        <tr style=" background-color:#D8E5D3;">

		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td colspan="16" style=" padding-bottom:2px">
		<% } else { %>
            <td colspan="8" style=" padding-bottom:2px">
		<% } %>
                <uc_PT:PageTool ID="ucPage" runat="server" />
            </td>

		<% if (Model.TableType == L_BudgetTableType.Query) { %>
            <td colspan="1" align="center" style=" padding-bottom:2px">
                <div class="budget-button-no-02">
                    <input type="button" value="+" onclick="Open(this, 1)" class="budget-submit-no-02" hidefocus="true" />
                </div>
            </td>
            <td colspan="5" G="1">&nbsp;</td>
		<% } %>

            <td colspan="1" align="center" style=" padding-bottom:2px">
                <div class="budget-button-no-02">
                    <input type="button" value="+" onclick="Open(this, 2)" class="budget-submit-no-02" hidefocus="true" />
                </div>
            </td>
			<td colspan="9" G="2">&nbsp;</td>

		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		<% } %>

            <td colspan="1" align="center" style=" padding-bottom:2px">
                <div class="budget-button-no-02">
                    <input type="button" value="+" onclick="Open(this, 3)" class="budget-submit-no-02" hidefocus="true" />
                </div>
            </td>
			<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %><td colspan="5" G="3">&nbsp;</td><% } %>
			<% else { %><td colspan="9" G="3">&nbsp;</td><% } %>
		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td>&nbsp;</td>
		<% } %>

            <td colspan="1" align="center" style=" padding-bottom:2px">
                <div class="budget-button-no-02">
                    <input type="button" value="+" onclick="Open(this, 4)" class="budget-submit-no-02" hidefocus="true" />
                </div>
            </td>
			<td colspan="8" G="4">&nbsp;</td>

		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td>&nbsp;</td>
		<% } %>

            <td colspan="1" align="center" style=" padding-bottom:2px">
                <div class="budget-button-no-02">
                    <input type="button" value="+" onclick="Open(this, 5)" class="budget-submit-no-02" hidefocus="true" />
                </div>
            </td>
            <td colspan="8" G="5">&nbsp;</td>
        </tr>
        <tr class="header">
        <% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
            <td class="first">全选<input type="checkbox" onclick="BudgetTable_CheckAll(this)"/></td>
			<td>编制单位</td>
			<td>类别</td>
			<td>类型</td>	
			<td>项目名称</td>
			<td>项目代号</td>
			<td>状态</td>
			<td>项目负责人</td>
			<td>经费来源</td>
			<td>软课题</td>
			<td class="warning">报警信息</td>
			<td>项目周期-起</td>
			<td>项目周期-止</td>
			<td>预算金额</td>
        <% } else { %>
            <td class="first">年度</td>
			<td>编制单位</td>
			<td>类别</td>
			<td>类型</td>	
			<td>项目名称</td>
			<td>项目代号</td>
			<td>项目负责人</td>
			<td>预算金额</td>
			<td>状态</td>
			<td G="1" class="hiden">项目周期-起</td>
			<td G="1" class="hiden">项目周期-止</td>
			<td G="1" class="hiden">年度进度</td>
			<td G="1" class="hiden">经费来源</td>
			<td G="1" class="hiden">软课题</td>
        <% } %>
			
		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td class="blank">&nbsp;</td>
		<% } %>

        <td>收入合计</td>
		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td>累计收入</td>
		<% } %>
        <td G="2" class="hiden">标准领报</td>
        <td G="2" class="hiden">项目经费</td>
        <td G="2" class="hiden">家底弥补</td>
        <td G="2" class="hiden">所家底</td>
        <td G="2" class="hiden">科技处家底</td>
        <td G="2" class="hiden">政治处家底</td>
        <td G="2" class="hiden">管理处家底</td>
        <td G="2" class="hiden">其他收入</td>
        <td G="2" class="hiden">上年转入</td>

		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td class="blank">&nbsp;</td>
		<% } %>
        <td>是否垫支</td>
		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td>累计垫支</td>
		<% } %>
        <td G="3" class="hiden">拟到经费总额</td>
        <td G="3" class="hiden">预计经费到位时间</td>
        <td G="3" class="hiden">垫支金额</td>
		<% if (Model.TableType == L_BudgetTableType.Query) { %>
			<td G="3" class="hiden">垫支转入</td>
		<% } %>
        <td G="3" class="hiden">预计归垫时间</td>
        <td G="3" class="hiden">归垫责任人</td>
		<% if (Model.TableType == L_BudgetTableType.Query) { %>
			<td G="3" class="hiden">垫支状态</td>
			<td G="3" class="hiden">尚未归垫</td>
			<td G="3" class="hiden">归垫后余额</td>
		<% } %>

		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td class="blank">&nbsp;</td>
		<% } %>
        <td>当年支出</td>
        <td G="4" class="hiden">设备费</td>
        <td G="4" class="hiden">材料费</td>
        <td G="4" class="hiden">协助费</td>
        <td G="4" class="hiden">业务费</td>
        <td G="4" class="hiden">分摊费用</td>
        <td G="4" class="hiden">成本性</td>
        <td G="4" class="hiden">公用费用</td>
        <td G="4" class="hiden">机关费支出</td>

		<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
			<td class="blank">&nbsp;</td>
		<% } %>
        <td>历年支出</td>
        <td G="5" class="hiden">设备费</td>
        <td G="5" class="hiden">材料费</td>
        <td G="5" class="hiden">协助费</td>
        <td G="5" class="hiden">业务费</td>
        <td G="5" class="hiden">分摊费用</td>
        <td G="5" class="hiden">成本性</td>
        <td G="5" class="hiden">公用费用</td>
        <td G="5" class="hiden">机关费支出</td>
    </tr>

        <% if (ViewData["QueryResult"] != null) { %>
        
            <% List<vw_Budget> lsQR = (List<vw_Budget>)ViewData["QueryResult"]; %>

            <% foreach (vw_Budget oItem in lsQR) { %>
                <tr class="body">
				<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
                    <td class="first">
                        <input type="checkbox" mark="Select"/>
                        <% if (Model.TableType == L_BudgetTableType.AppoverList){ %>
                            <input type="hidden" value="<%=oItem.ProjectCode %>"/>
                        <% } else if (Model.TableType == L_BudgetTableType.AdjustList) { %>
                            <input type="hidden" value="<%=oItem.BudgetGuid %>"/>
                            <input type="hidden" value="<%=oItem.BudgetStatus %>"/>
                        <% } %>                        
                    </td>
                    <td><%=oItem.DepartmentName %>&nbsp;</td>
					<td><%=oItem.ProjectCategoryName %>&nbsp;</td>
                    <td><%=oItem.ProjectTypeName %>&nbsp;</td>
                    <td><a style="color:Blue; text-decoration:underline; cursor:pointer" onclick="OpenBudegtPage('<%=oItem.BudgetGuid %>', '<%=oItem.IsHis %>', '<%=oItem.Version %>', '<%=Model.BudgetLinkType %>')" ><%=oItem.ProjectName %></a>&nbsp;</td>
                    <td><%=oItem.ProjectCode %>&nbsp;</td>
					<td><%=oItem.BudgetStatusName %>&nbsp;</td>                    
                    <td><%=oItem.ProjectPICName %>&nbsp;</td>
					<td><%=oItem.FundsSources %>&nbsp;</td>
                    <td><%=oItem.IsSoft %>&nbsp;</td>
					<td><%=oItem.Wain %>&nbsp;</td>
                    <td><%=oItem.ProjectBeginTime %>&nbsp;</td>
                    <td><%=oItem.ProjectEndTime %>&nbsp;</td>
					<td><%=oItem.BudgetAmount %>&nbsp;</td>
				<% } else { %>
					<td class="first"><%=oItem.BudgetYear %>&nbsp;</td>
					<td><%=oItem.ProjectCategoryName %>&nbsp;</td>
                    <td><%=oItem.ProjectTypeName %>&nbsp;</td>
                    <td><%=oItem.DepartmentName %>&nbsp;</td>
                    <td><a style="color:Blue; text-decoration:underline; cursor:pointer" onclick="OpenBudegtPage('<%=oItem.BudgetGuid %>', '<%=oItem.IsHis %>', '<%=oItem.Version %>', '<%=Model.BudgetLinkType %>')" ><%=oItem.ProjectName %></a>&nbsp;</td>
                    <td><%=oItem.ProjectCode %>&nbsp;</td>
                    <td><%=oItem.ProjectPICName %>&nbsp;</td>
					<td><%=oItem.BudgetAmount %>&nbsp;</td>
                    <td><%=oItem.BudgetStatusName %><font style="color:Red"><%=(oItem.IsHis.Value?"[历史]":"") %></font>&nbsp;</td>
                    <td G="1"><%=oItem.ProjectBeginTime %>&nbsp;</td>
                    <td G="1"><%=oItem.ProjectEndTime %>&nbsp;</td>
                    <td G="1"><%=oItem.AnnualProgress %>&nbsp;</td>
                    <td G="1"><%=oItem.FundsSources %>&nbsp;</td>
                    <td G="1"><%=oItem.IsSoft %>&nbsp;</td>
				<% } %>
                    
				<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
					<td class="blank">&nbsp;</td>
				<% } %>
                    <td><%=(oItem.In_StFu + oItem.In_PrFu + oItem.In_Su + oItem.In_DeSu + oItem.In_ScSu + oItem.In_PoSu + oItem.In_MaSu + oItem.In_O + oItem.In_B).ToString("f2") %>&nbsp;</td>
					<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
					<td><%=oItem.In_G.ToString("f2") %></td>
					<% } %>
                    <td G="2"><%=oItem.In_StFu.ToString("f2") %>&nbsp;</td>
                    <td G="2"><%=oItem.In_PrFu.ToString("f2") %>&nbsp;</td>
                    <td G="2"><%=oItem.In_Su.ToString("f2") %>&nbsp;</td>
                    <td G="2"><%=oItem.In_DeSu.ToString("f2") %>&nbsp;</td>
                    <td G="2"><%=oItem.In_ScSu.ToString("f2") %>&nbsp;</td>
                    <td G="2"><%=oItem.In_PoSu.ToString("f2") %>&nbsp;</td>
                    <td G="2"><%=oItem.In_MaSu.ToString("f2") %>&nbsp;</td>
                    <td G="2"><%=oItem.In_O.ToString("f2") %>&nbsp;</td>
                    <td G="2"><%=oItem.In_B.ToString("f2") %>&nbsp;</td>

				<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
					<td class="blank">&nbsp;</td>
				<% } %>
                    <td><%=oItem.IsAdvence %>&nbsp;</td>
				<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
					<td><%=oItem.AdvenceG.ToString("f2") %>&nbsp;</td>
				<% } %>
                    <td G="3"><%=oItem.AdvencePlanAmount.ToString("f2") %>&nbsp;</td>
                    <td G="3"><%=oItem.AdvencePlanTime %>&nbsp;</td>
                    <td G="3"><%=oItem.AdvenceAmount.ToString("f2") %>&nbsp;</td>
					<% if (Model.TableType == L_BudgetTableType.Query) { %>
						<td G="3"><%=oItem.AdvenceBalance.ToString("f2") %>&nbsp;</td>
					<% } %>
                    <td G="3"><%=oItem.AdvenceReturnTime %>&nbsp;</td>
                    <td G="3"><%=oItem.AdvencePICName %>&nbsp;</td>
					<% if (Model.TableType == L_BudgetTableType.Query) { %>
						<td G="3" class="hiden"><%=oItem.AdvenceStatusName %>&nbsp;</td>
						<td G="3" class="hiden"><%=oItem.AdvenceNoReturn %>&nbsp;</td>
						<td G="3" class="hiden"><%=oItem.AdvenceLeft %>&nbsp;</td>
					<% } %>

				<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
					<td class="blank">&nbsp;</td>
				<% } %>
                    <td><%=oItem.BudgetPay_Amount.ToString("f2") %>&nbsp;</td>
                    <td G="4"><%=oItem.BuPa_Eq.ToString("f2") %>&nbsp;</td>
                    <td G="4"><%=oItem.BuPa_Ma.ToString("f2") %>&nbsp;</td>
                    <td G="4"><%=oItem.BuPa_Co.ToString("f2") %>&nbsp;</td>
                    <td G="4"><%=oItem.BuPa_Bu.ToString("f2") %>&nbsp;</td>
                    <td G="4"><%=oItem.BuPa_Ch.ToString("f2") %>&nbsp;</td>
                    <td G="4"><%=oItem.BuPa_Pr.ToString("f2") %>&nbsp;</td>
                    <td G="4"><%=oItem.BuPa_Pu.ToString("f2") %>&nbsp;</td>
                    <td G="4"><%=oItem.BuPa_De.ToString("f2") %>&nbsp;</td>

				<% if (Model.TableType == L_BudgetTableType.AppoverList || Model.TableType == L_BudgetTableType.AdjustList) { %>
					<td class="blank">&nbsp;</td>
				<% } %>
                    <td><%=oItem.His_Amount.ToString("f2") %>&nbsp;</td>
                    <td G="5"><%=oItem.Hi_Eq.ToString("f2") %>&nbsp;</td>
                    <td G="5"><%=oItem.Hi_Ma.ToString("f2") %>&nbsp;</td>
                    <td G="5"><%=oItem.Hi_Co.ToString("f2") %>&nbsp;</td>
                    <td G="5"><%=oItem.Hi_Bu.ToString("f2") %>&nbsp;</td>
                    <td G="5"><%=oItem.Hi_Ch.ToString("f2") %>&nbsp;</td>
                    <td G="5"><%=oItem.Hi_Pr.ToString("f2") %>&nbsp;</td>
                    <td G="5"><%=oItem.Hi_Pu.ToString("f2") %>&nbsp;</td>
                    <td G="5"><%=oItem.Hi_De.ToString("f2") %>&nbsp;</td>
                </tr>
            <% } %>

        <% } %>

    </table>